<%--
  Created by IntelliJ IDEA.
  User: xiaoji
  Date: 2015/1/7
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="z" uri="/WEB-INF/lib/zerdoor.tld"%>
<html>
<head>
    <title><spring:message code='usercenter.index.title' /></title>
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<jsp:include page="../public/header.jsp">
    <jsp:param    name="usercenter"    value="true"    />
</jsp:include>
<jsp:include page="../usercenter/leftMenu.jsp"></jsp:include>
<div class="member_box">
    <div class="member_title">
        <spring:message code='arbitration.arbitrationDetail.msg1' />
    </div>
    <div class="sflsbox">
        <div class="member_form">
            <ul>
                <li class="clearfix">
                    <dl class="clearfix">
                        <dt><spring:message code='arbitration.arbitrationDetail.msg2' /></dt>
                        <dd>
                            <label><b>${detail.title}</b></label>
                            <label class="shuxing">
                                <span>

                                    <c:if test="${detail.status==101001}">
                                        <spring:message code='arbitration.arbitrationDetail.msg3' />
                                    </c:if>
                                    <c:if test="${detail.status!=101001}">
                                        <spring:message code='arbitration.arbitrationDetail.msg4' />
                                    </c:if>
                                </span>
                            </label>
                        </dd>
                    </dl>
                </li>
                <li class="clearfix">
                    <dl class="clearfix">
                        <dt><spring:message code='arbitration.arbitrationDetail.msg5' /></dt>
                        <dd>
                            <label><f:formatDate value="${detail.applyTime}" type="both"/> </label><label style="color: #FF0000">
                            <spring:message code='arbitration.arbitrationDetail.msg6' />
                        </label>
                        </dd>
                    </dl>
                </li>
                <li class="clearfix">
                    <dl class="clearfix">
                        <dt><spring:message code='arbitration.arbitrationDetail.msg7' /></dt>
                        <dd>
                            <div class="sflsbox">
                                <c:forEach var="a" items="${discuss}">
                                <div class="sflslist">
                                    <div class="pepole_img"><img src="${path}/${a.headPortrait}" width="70" height="70"></div>
                                    <div class="pepole_cont">
                                        <div class="pepole_word">${a.content}</div>
                                        <div class="pepole_file">
                                            <ul class="clearfix">
                                                <c:forTokens items="${a.attachment}" delims="," var="dimg">
                                                <li>
                                                    <img src="${path}/${dimg}" width="56" height="70">
                                                    <p>${z:subStringLastAfter(dimg, "/")}</p>
                                                </li>
                                                </c:forTokens>
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="clr"></div>
                                </div>
                                </c:forEach>
                            </div>
                        </dd>
                    </dl>
                </li>
                <li class="clearfix">
                    <dl class="clearfix">
                        <dt><spring:message code='arbitration.arbitrationDetail.msg8' /></dt>
                        <dd>
                            ${detail.result}
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <div class="member_form zcsqform">
        <ul>
            <li class="clearfix">
                <dl class="clearfix">
                    <dt><spring:message code='arbitration.arbitrationDetail.msg9' /></dt>
                    <dd>
                        <textarea id="content" name="content" class="sumarry650"></textarea>
                    </dd>
                </dl>
            </li>
            <li class="clearfix">
                <dl class="clearfix">
                    <dt><spring:message code='arbitration.arbitrationDetail.msg10' /></dt>
                    <dd>
                        <div class="pepole_files clearfix">
                            <ul class="clearfix" id="showPic">

                            </ul>
                            <label for="fulAchievements"   class="btn_addfile"><spring:message code='arbitration.arbitrationDetail.msg11' /></label>
                            <input style="display: none" type="file" name="file" id="fulAchievements" onchange="f_file_upload()"  />
                            <input type="hidden" name="attachment" id="attachment" value="">
                        </div>
                    </dd>
                </dl>
            </li>
            <li class="clearfix">
                <dl class="clearfix">
                    <dt>&nbsp;</dt>
                    <dd><input type="button" id="saveAribitration" name="" value="<spring:message code='arbitration.arbitrationDetail.msg12' />" class="btn60"></dd>
                </dl>
            </li>
        </ul>
    </div>
</div>
<script type="text/javascript" src="${path}/js/ajaxfileupload.js"></script>
<script>
    //删除上传图片
    function deleteImg(num){
        //删除元素
        var url = $("#img"+num).attr("surl");
        $("#img"+num).remove();
        //为隐藏变量重新赋值
        var attachment = $("#attachment").val();
        var attachment2="";
        var indexa = attachment.indexOf(attachment);
        if(indexa != -1){
            var arr = attachment.split(",");
            if(arr.length >0 ){
                for(var i=0; i<arr.length; i++){
                    var tempobj = arr[i];
                    if(url == arr[i]){
                        arr.splice(i,1);
                    }
                }
            }
            console.log(arr);
            attachment2 = arr.join(",");
            $("#attachment").val(attachment2);
        }
    }
    //上传图片
    var uploadnum = 1;
    function f_file_upload(){
        $.ajaxFileUpload({
            url: '${path}/fileUpload/upload_resource_file.html',
            secureuri: false,
            fileElementId: 'fulAchievements',
            success: function (data) {
                //data = $.parseJSON(data);
                var data2 = data.split(",");
                var url = data2[0].replace(" ","");
                var fileName = data2[1].replace(" ","");

                var htmlStr = '<li id="img'+uploadnum+'" surl="'+url+'">'+
                        '<img src="${path}/'+url+'" width="56" height="70" />'+
                        '<p>'+fileName+'</p>'+
                        '<span class="ico_del" onclick="deleteImg('+uploadnum+')">×</span>'+
                        '</li>';
                $("#showPic").append(htmlStr);
                if($("#attachment").val() == ''){
                    $("#attachment").val(url);
                }else{
                    $("#attachment").val($("#attachment").val()+","+url);
                }
                uploadnum++;
                //给图片绑定事件
            },
            error:function(data){

            }
        });
    }
    $(function(){
        $("#saveAribitration").click(function(){
            if($("#content").val()!=''){
                $.post("${path}/arbitration/addItemDiscuss.html",{
                    content : $("#content").val(),
                    attachment : $("#attachment").val(),
                    arbitrateId : '${arbitrateId}',
                    contractId : '${contractId}'
                },function(data){
                    if(data.errormsg ==undefined){
                        window.location = "${path}/arbitration/arbitrationDetail.html?contractId=${contractId}&arbitrateId="+data.arbitrateId;
                    }else{
                        alert("<spring:message code='arbitration.arbitrationDetail.msg13' />");
                    }
                },"json");
            }
        });
    });
</script>
<jsp:include page="../usercenter/leftMenuEnd.jsp"></jsp:include>
<jsp:include page="../public/footer.jsp"></jsp:include>
</body>
</html>